package org.sag.gui;

import java.awt.BorderLayout;
import java.util.Vector;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;

import org.sag.coverage.PolicySpreadSheetTestSuite;

public class TestPanel extends JPanel{
	private XPA xpa;

	public TestPanel(XPA xpa) {
		this.xpa = xpa;	
		setLayout(new BorderLayout());
		try {
			PolicySpreadSheetTestSuite testSuite = new PolicySpreadSheetTestSuite("tests//kmarket-tests.xls","tests//kmarket-blue-policy.xml");
			String[] columnNames = { "No", "Test Name", "Request File", "Expected Response", "Actual Response", "Verdict"};
			JScrollPane scrollpane = new JScrollPane(new GeneralTablePanel(testSuite.getTestData(), columnNames, 7));
			
			JSplitPane jSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
			jSplitPane.setLeftComponent(scrollpane);
			jSplitPane.setRightComponent(sampleRequestPanel());
			jSplitPane.setResizeWeight(0.7);

			add(jSplitPane, BorderLayout.CENTER);
		}
		catch (Exception e) {
			
		}
	}
	
	public void generateTests(){

	}

	public void runTests(){
		try {
			PolicySpreadSheetTestSuite testSuite = new PolicySpreadSheetTestSuite("tests//kmarket-tests.xls","tests//kmarket-blue-policy.xml");
		}
		catch (Exception e) {
			
		}
	}
	
	public JScrollPane sampleRequestPanel() {

		Vector<Object> v1 = new Vector<Object>();
		v1.add("Subject");
		v1.add("String");
		v1.add("role");
		v1.add("doctor");

		Vector<Object> v2 = new Vector<Object>();
		v2.add("Resource");
		v2.add("String");
		v2.add("Document");
		v2.add("patientrecord");

		Vector<Vector<Object>> data = new Vector<Vector<Object>>();
		data.add(v1);
		data.add(v2);

		String[] columnNames = { "Category", "Type", "Name", "Value" };
		return new JScrollPane(new GeneralTablePanel(data, columnNames, 4));

	}


}
